{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "def51c67",
   "metadata": {},
   "source": [
    "- 安装tushare\n",
    "    - pip install tushare"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e6ed398a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tushare as ts\n",
    "import pandas as pd\n",
    "from pandas import DataFrame,Series\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 615,
   "id": "7d770862",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>trade_date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220106</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220105</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220104</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211231</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211230</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1824</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20140709</td>\n",
       "      <td>29.51</td>\n",
       "      <td>30.39</td>\n",
       "      <td>28.01</td>\n",
       "      <td>28.62</td>\n",
       "      <td>31.02</td>\n",
       "      <td>-2.40</td>\n",
       "      <td>-7.7400</td>\n",
       "      <td>192462.80</td>\n",
       "      <td>558930.231</td>\n",
       "      <td>28.068</td>\n",
       "      <td>105290.542</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1825</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20140708</td>\n",
       "      <td>32.45</td>\n",
       "      <td>32.45</td>\n",
       "      <td>29.83</td>\n",
       "      <td>31.02</td>\n",
       "      <td>29.50</td>\n",
       "      <td>1.52</td>\n",
       "      <td>5.1500</td>\n",
       "      <td>316677.59</td>\n",
       "      <td>994377.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1826</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20140707</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>26.82</td>\n",
       "      <td>2.68</td>\n",
       "      <td>9.9900</td>\n",
       "      <td>10437.41</td>\n",
       "      <td>30790.360</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1827</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20140704</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>24.38</td>\n",
       "      <td>2.44</td>\n",
       "      <td>10.0100</td>\n",
       "      <td>2918.39</td>\n",
       "      <td>7827.122</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1828</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20140703</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>16.93</td>\n",
       "      <td>7.45</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>3956.52</td>\n",
       "      <td>9623.016</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1829 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        ts_code trade_date   open   high    low  close  pre_close  change  \\\n",
       "0     603369.SH   20220106  53.00  54.00  52.52  52.72      53.42   -0.70   \n",
       "1     603369.SH   20220105  53.69  54.59  52.89  53.42      53.75   -0.33   \n",
       "2     603369.SH   20220104  54.40  54.69  52.56  53.75      54.40   -0.65   \n",
       "3     603369.SH   20211231  55.60  55.60  53.92  54.40      55.18   -0.78   \n",
       "4     603369.SH   20211230  54.78  55.64  54.33  55.18      54.50    0.68   \n",
       "...         ...        ...    ...    ...    ...    ...        ...     ...   \n",
       "1824  603369.SH   20140709  29.51  30.39  28.01  28.62      31.02   -2.40   \n",
       "1825  603369.SH   20140708  32.45  32.45  29.83  31.02      29.50    1.52   \n",
       "1826  603369.SH   20140707  29.50  29.50  29.50  29.50      26.82    2.68   \n",
       "1827  603369.SH   20140704  26.82  26.82  26.82  26.82      24.38    2.44   \n",
       "1828  603369.SH   20140703  20.32  24.38  20.32  24.38      16.93    7.45   \n",
       "\n",
       "      pct_chg        vol      amount     ma5      ma_v_5     ma20  \\\n",
       "0     -1.3104   72224.89  382900.560  53.894   79426.698  57.1220   \n",
       "1     -0.6140   85255.00  458109.555  54.250   90962.866  57.3785   \n",
       "2     -1.1949   84020.93  447463.911  55.046   98373.016  57.5270   \n",
       "3     -1.4136   88366.19  480203.487  55.472  103132.294  57.6735   \n",
       "4      1.2477   67266.48  371088.242  56.274  101832.908  57.7945   \n",
       "...       ...        ...         ...     ...         ...      ...   \n",
       "1824  -7.7400  192462.80  558930.231  28.068  105290.542      NaN   \n",
       "1825   5.1500  316677.59  994377.000     NaN         NaN      NaN   \n",
       "1826   9.9900   10437.41   30790.360     NaN         NaN      NaN   \n",
       "1827  10.0100    2918.39    7827.122     NaN         NaN      NaN   \n",
       "1828  44.0000    3956.52    9623.016     NaN         NaN      NaN   \n",
       "\n",
       "          ma_v_20     ma50      ma_v_50  \n",
       "0     111990.3890  56.1138  117785.8494  \n",
       "1     118108.9355  56.0012  119193.2006  \n",
       "2     120488.8350  55.8966  119760.4852  \n",
       "3     120670.0260  55.7864  121287.9868  \n",
       "4     122491.7510  55.6938  124537.3562  \n",
       "...           ...      ...          ...  \n",
       "1824          NaN      NaN          NaN  \n",
       "1825          NaN      NaN          NaN  \n",
       "1826          NaN      NaN          NaN  \n",
       "1827          NaN      NaN          NaN  \n",
       "1828          NaN      NaN          NaN  \n",
       "\n",
       "[1829 rows x 17 columns]"
      ]
     },
     "execution_count": 615,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取某只股票历史数据\n",
    "# code 股票代码\n",
    "# start 开始时间\n",
    "# end 结束时间 不写默认为当日\n",
    "ts.set_token('13fbc96d521a2cf4b7f751230d9b06c764a21a6ebcf39167cb0b5a4e')\n",
    "df = ts.pro_bar(ts_code='603369.sh', start_date='20000101',freq='D',ma=[5, 20, 50])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 616,
   "id": "6de358c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将数据保存到本地\n",
    "file_name = 'jinshiyuan.csv'\n",
    "df.to_csv('./'+file_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 617,
   "id": "dac8ccd5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>ts_code</th>\n",
       "      <th>trade_date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220106</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220105</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220104</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211231</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211230</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0    ts_code  trade_date   open   high    low  close  pre_close  \\\n",
       "0           0  603369.SH    20220106  53.00  54.00  52.52  52.72      53.42   \n",
       "1           1  603369.SH    20220105  53.69  54.59  52.89  53.42      53.75   \n",
       "2           2  603369.SH    20220104  54.40  54.69  52.56  53.75      54.40   \n",
       "3           3  603369.SH    20211231  55.60  55.60  53.92  54.40      55.18   \n",
       "4           4  603369.SH    20211230  54.78  55.64  54.33  55.18      54.50   \n",
       "\n",
       "   change  pct_chg       vol      amount     ma5      ma_v_5     ma20  \\\n",
       "0   -0.70  -1.3104  72224.89  382900.560  53.894   79426.698  57.1220   \n",
       "1   -0.33  -0.6140  85255.00  458109.555  54.250   90962.866  57.3785   \n",
       "2   -0.65  -1.1949  84020.93  447463.911  55.046   98373.016  57.5270   \n",
       "3   -0.78  -1.4136  88366.19  480203.487  55.472  103132.294  57.6735   \n",
       "4    0.68   1.2477  67266.48  371088.242  56.274  101832.908  57.7945   \n",
       "\n",
       "       ma_v_20     ma50      ma_v_50  \n",
       "0  111990.3890  56.1138  117785.8494  \n",
       "1  118108.9355  56.0012  119193.2006  \n",
       "2  120488.8350  55.8966  119760.4852  \n",
       "3  120670.0260  55.7864  121287.9868  \n",
       "4  122491.7510  55.6938  124537.3562  "
      ]
     },
     "execution_count": 617,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取本地数据\n",
    "df = pd.read_csv('./'+file_name)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebb7986d",
   "metadata": {},
   "source": [
    "# 对所读取数据做处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 618,
   "id": "e4dda545",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>trade_date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220106</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220105</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20220104</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211231</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20211230</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     ts_code  trade_date   open   high    low  close  pre_close  change  \\\n",
       "0  603369.SH    20220106  53.00  54.00  52.52  52.72      53.42   -0.70   \n",
       "1  603369.SH    20220105  53.69  54.59  52.89  53.42      53.75   -0.33   \n",
       "2  603369.SH    20220104  54.40  54.69  52.56  53.75      54.40   -0.65   \n",
       "3  603369.SH    20211231  55.60  55.60  53.92  54.40      55.18   -0.78   \n",
       "4  603369.SH    20211230  54.78  55.64  54.33  55.18      54.50    0.68   \n",
       "\n",
       "   pct_chg       vol      amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "0  -1.3104  72224.89  382900.560  53.894   79426.698  57.1220  111990.3890   \n",
       "1  -0.6140  85255.00  458109.555  54.250   90962.866  57.3785  118108.9355   \n",
       "2  -1.1949  84020.93  447463.911  55.046   98373.016  57.5270  120488.8350   \n",
       "3  -1.4136  88366.19  480203.487  55.472  103132.294  57.6735  120670.0260   \n",
       "4   1.2477  67266.48  371088.242  56.274  101832.908  57.7945  122491.7510   \n",
       "\n",
       "      ma50      ma_v_50  \n",
       "0  56.1138  117785.8494  \n",
       "1  56.0012  119193.2006  \n",
       "2  55.8966  119760.4852  \n",
       "3  55.7864  121287.9868  \n",
       "4  55.6938  124537.3562  "
      ]
     },
     "execution_count": 618,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 删除某列\n",
    "# axis 1-列 0-行\n",
    "df.drop(labels='Unnamed: 0',axis=1,inplace=True)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 619,
   "id": "c8b28306",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1829 entries, 0 to 1828\n",
      "Data columns (total 17 columns):\n",
      " #   Column      Non-Null Count  Dtype  \n",
      "---  ------      --------------  -----  \n",
      " 0   ts_code     1829 non-null   object \n",
      " 1   trade_date  1829 non-null   int64  \n",
      " 2   open        1829 non-null   float64\n",
      " 3   high        1829 non-null   float64\n",
      " 4   low         1829 non-null   float64\n",
      " 5   close       1829 non-null   float64\n",
      " 6   pre_close   1829 non-null   float64\n",
      " 7   change      1829 non-null   float64\n",
      " 8   pct_chg     1829 non-null   float64\n",
      " 9   vol         1829 non-null   float64\n",
      " 10  amount      1829 non-null   float64\n",
      " 11  ma5         1825 non-null   float64\n",
      " 12  ma_v_5      1825 non-null   float64\n",
      " 13  ma20        1810 non-null   float64\n",
      " 14  ma_v_20     1810 non-null   float64\n",
      " 15  ma50        1780 non-null   float64\n",
      " 16  ma_v_50     1780 non-null   float64\n",
      "dtypes: float64(15), int64(1), object(1)\n",
      "memory usage: 243.0+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 620,
   "id": "bfe83045",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1829 entries, 0 to 1828\n",
      "Data columns (total 17 columns):\n",
      " #   Column      Non-Null Count  Dtype         \n",
      "---  ------      --------------  -----         \n",
      " 0   ts_code     1829 non-null   object        \n",
      " 1   trade_date  1829 non-null   datetime64[ns]\n",
      " 2   open        1829 non-null   float64       \n",
      " 3   high        1829 non-null   float64       \n",
      " 4   low         1829 non-null   float64       \n",
      " 5   close       1829 non-null   float64       \n",
      " 6   pre_close   1829 non-null   float64       \n",
      " 7   change      1829 non-null   float64       \n",
      " 8   pct_chg     1829 non-null   float64       \n",
      " 9   vol         1829 non-null   float64       \n",
      " 10  amount      1829 non-null   float64       \n",
      " 11  ma5         1825 non-null   float64       \n",
      " 12  ma_v_5      1825 non-null   float64       \n",
      " 13  ma20        1810 non-null   float64       \n",
      " 14  ma_v_20     1810 non-null   float64       \n",
      " 15  ma50        1780 non-null   float64       \n",
      " 16  ma_v_50     1780 non-null   float64       \n",
      "dtypes: datetime64[ns](1), float64(15), object(1)\n",
      "memory usage: 243.0+ KB\n"
     ]
    }
   ],
   "source": [
    "df['trade_date']=pd.to_datetime(df['trade_date'],format='%Y%m%d')\n",
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 621,
   "id": "08f905b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>trade_date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>2022-01-06</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>2022-01-05</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>2022-01-04</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>2021-12-31</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>2021-12-30</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     ts_code trade_date   open   high    low  close  pre_close  change  \\\n",
       "0  603369.SH 2022-01-06  53.00  54.00  52.52  52.72      53.42   -0.70   \n",
       "1  603369.SH 2022-01-05  53.69  54.59  52.89  53.42      53.75   -0.33   \n",
       "2  603369.SH 2022-01-04  54.40  54.69  52.56  53.75      54.40   -0.65   \n",
       "3  603369.SH 2021-12-31  55.60  55.60  53.92  54.40      55.18   -0.78   \n",
       "4  603369.SH 2021-12-30  54.78  55.64  54.33  55.18      54.50    0.68   \n",
       "\n",
       "   pct_chg       vol      amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "0  -1.3104  72224.89  382900.560  53.894   79426.698  57.1220  111990.3890   \n",
       "1  -0.6140  85255.00  458109.555  54.250   90962.866  57.3785  118108.9355   \n",
       "2  -1.1949  84020.93  447463.911  55.046   98373.016  57.5270  120488.8350   \n",
       "3  -1.4136  88366.19  480203.487  55.472  103132.294  57.6735  120670.0260   \n",
       "4   1.2477  67266.48  371088.242  56.274  101832.908  57.7945  122491.7510   \n",
       "\n",
       "      ma50      ma_v_50  \n",
       "0  56.1138  117785.8494  \n",
       "1  56.0012  119193.2006  \n",
       "2  55.8966  119760.4852  \n",
       "3  55.7864  121287.9868  \n",
       "4  55.6938  124537.3562  "
      ]
     },
     "execution_count": 621,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 622,
   "id": "1f46dc6b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-01-06</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-05</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-04</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-30</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              ts_code   open   high    low  close  pre_close  change  pct_chg  \\\n",
       "trade_date                                                                      \n",
       "2022-01-06  603369.SH  53.00  54.00  52.52  52.72      53.42   -0.70  -1.3104   \n",
       "2022-01-05  603369.SH  53.69  54.59  52.89  53.42      53.75   -0.33  -0.6140   \n",
       "2022-01-04  603369.SH  54.40  54.69  52.56  53.75      54.40   -0.65  -1.1949   \n",
       "2021-12-31  603369.SH  55.60  55.60  53.92  54.40      55.18   -0.78  -1.4136   \n",
       "2021-12-30  603369.SH  54.78  55.64  54.33  55.18      54.50    0.68   1.2477   \n",
       "\n",
       "                 vol      amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "trade_date                                                                   \n",
       "2022-01-06  72224.89  382900.560  53.894   79426.698  57.1220  111990.3890   \n",
       "2022-01-05  85255.00  458109.555  54.250   90962.866  57.3785  118108.9355   \n",
       "2022-01-04  84020.93  447463.911  55.046   98373.016  57.5270  120488.8350   \n",
       "2021-12-31  88366.19  480203.487  55.472  103132.294  57.6735  120670.0260   \n",
       "2021-12-30  67266.48  371088.242  56.274  101832.908  57.7945  122491.7510   \n",
       "\n",
       "               ma50      ma_v_50  \n",
       "trade_date                        \n",
       "2022-01-06  56.1138  117785.8494  \n",
       "2022-01-05  56.0012  119193.2006  \n",
       "2022-01-04  55.8966  119760.4852  \n",
       "2021-12-31  55.7864  121287.9868  \n",
       "2021-12-30  55.6938  124537.3562  "
      ]
     },
     "execution_count": 622,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将trade_date作为数据的行索引\n",
    "df.set_index('trade_date',inplace=True)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 623,
   "id": "483ac299",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "240"
      ]
     },
     "execution_count": 623,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 该股票当日涨幅比当日开盘价格大于%3的日期\n",
    "df_z = df.loc[df['change']/df['open'] > 0.03].index\n",
    "len(df_z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 624,
   "id": "59f989cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "555"
      ]
     },
     "execution_count": 624,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 该股票当日收盘比前日收盘跌幅超过2%的日期\n",
    "df_d = df.loc[(df['open'] - df['close'].shift(1))/df['close'] < -0.02].index\n",
    "len(df_d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 625,
   "id": "ee15dea8",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp/ipykernel_3304/2568845036.py:1: FutureWarning: Value based partial slicing on non-monotonic DatetimeIndexes with non-existing keys is deprecated and will raise a KeyError in a future Version.\n",
      "  new_df = df['2011-01':]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-01-06</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>53.00</td>\n",
       "      <td>54.00</td>\n",
       "      <td>52.52</td>\n",
       "      <td>52.72</td>\n",
       "      <td>53.42</td>\n",
       "      <td>-0.70</td>\n",
       "      <td>-1.3104</td>\n",
       "      <td>72224.89</td>\n",
       "      <td>382900.560</td>\n",
       "      <td>53.894</td>\n",
       "      <td>79426.698</td>\n",
       "      <td>57.1220</td>\n",
       "      <td>111990.3890</td>\n",
       "      <td>56.1138</td>\n",
       "      <td>117785.8494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-05</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>53.69</td>\n",
       "      <td>54.59</td>\n",
       "      <td>52.89</td>\n",
       "      <td>53.42</td>\n",
       "      <td>53.75</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-0.6140</td>\n",
       "      <td>85255.00</td>\n",
       "      <td>458109.555</td>\n",
       "      <td>54.250</td>\n",
       "      <td>90962.866</td>\n",
       "      <td>57.3785</td>\n",
       "      <td>118108.9355</td>\n",
       "      <td>56.0012</td>\n",
       "      <td>119193.2006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-04</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-30</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>54.78</td>\n",
       "      <td>55.64</td>\n",
       "      <td>54.33</td>\n",
       "      <td>55.18</td>\n",
       "      <td>54.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.2477</td>\n",
       "      <td>67266.48</td>\n",
       "      <td>371088.242</td>\n",
       "      <td>56.274</td>\n",
       "      <td>101832.908</td>\n",
       "      <td>57.7945</td>\n",
       "      <td>122491.7510</td>\n",
       "      <td>55.6938</td>\n",
       "      <td>124537.3562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-09</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>29.51</td>\n",
       "      <td>30.39</td>\n",
       "      <td>28.01</td>\n",
       "      <td>28.62</td>\n",
       "      <td>31.02</td>\n",
       "      <td>-2.40</td>\n",
       "      <td>-7.7400</td>\n",
       "      <td>192462.80</td>\n",
       "      <td>558930.231</td>\n",
       "      <td>28.068</td>\n",
       "      <td>105290.542</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-08</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>32.45</td>\n",
       "      <td>32.45</td>\n",
       "      <td>29.83</td>\n",
       "      <td>31.02</td>\n",
       "      <td>29.50</td>\n",
       "      <td>1.52</td>\n",
       "      <td>5.1500</td>\n",
       "      <td>316677.59</td>\n",
       "      <td>994377.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-07</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>29.50</td>\n",
       "      <td>26.82</td>\n",
       "      <td>2.68</td>\n",
       "      <td>9.9900</td>\n",
       "      <td>10437.41</td>\n",
       "      <td>30790.360</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-04</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.82</td>\n",
       "      <td>24.38</td>\n",
       "      <td>2.44</td>\n",
       "      <td>10.0100</td>\n",
       "      <td>2918.39</td>\n",
       "      <td>7827.122</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-03</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>16.93</td>\n",
       "      <td>7.45</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>3956.52</td>\n",
       "      <td>9623.016</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1829 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              ts_code   open   high    low  close  pre_close  change  pct_chg  \\\n",
       "trade_date                                                                      \n",
       "2022-01-06  603369.SH  53.00  54.00  52.52  52.72      53.42   -0.70  -1.3104   \n",
       "2022-01-05  603369.SH  53.69  54.59  52.89  53.42      53.75   -0.33  -0.6140   \n",
       "2022-01-04  603369.SH  54.40  54.69  52.56  53.75      54.40   -0.65  -1.1949   \n",
       "2021-12-31  603369.SH  55.60  55.60  53.92  54.40      55.18   -0.78  -1.4136   \n",
       "2021-12-30  603369.SH  54.78  55.64  54.33  55.18      54.50    0.68   1.2477   \n",
       "...               ...    ...    ...    ...    ...        ...     ...      ...   \n",
       "2014-07-09  603369.SH  29.51  30.39  28.01  28.62      31.02   -2.40  -7.7400   \n",
       "2014-07-08  603369.SH  32.45  32.45  29.83  31.02      29.50    1.52   5.1500   \n",
       "2014-07-07  603369.SH  29.50  29.50  29.50  29.50      26.82    2.68   9.9900   \n",
       "2014-07-04  603369.SH  26.82  26.82  26.82  26.82      24.38    2.44  10.0100   \n",
       "2014-07-03  603369.SH  20.32  24.38  20.32  24.38      16.93    7.45  44.0000   \n",
       "\n",
       "                  vol      amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "trade_date                                                                    \n",
       "2022-01-06   72224.89  382900.560  53.894   79426.698  57.1220  111990.3890   \n",
       "2022-01-05   85255.00  458109.555  54.250   90962.866  57.3785  118108.9355   \n",
       "2022-01-04   84020.93  447463.911  55.046   98373.016  57.5270  120488.8350   \n",
       "2021-12-31   88366.19  480203.487  55.472  103132.294  57.6735  120670.0260   \n",
       "2021-12-30   67266.48  371088.242  56.274  101832.908  57.7945  122491.7510   \n",
       "...               ...         ...     ...         ...      ...          ...   \n",
       "2014-07-09  192462.80  558930.231  28.068  105290.542      NaN          NaN   \n",
       "2014-07-08  316677.59  994377.000     NaN         NaN      NaN          NaN   \n",
       "2014-07-07   10437.41   30790.360     NaN         NaN      NaN          NaN   \n",
       "2014-07-04    2918.39    7827.122     NaN         NaN      NaN          NaN   \n",
       "2014-07-03    3956.52    9623.016     NaN         NaN      NaN          NaN   \n",
       "\n",
       "               ma50      ma_v_50  \n",
       "trade_date                        \n",
       "2022-01-06  56.1138  117785.8494  \n",
       "2022-01-05  56.0012  119193.2006  \n",
       "2022-01-04  55.8966  119760.4852  \n",
       "2021-12-31  55.7864  121287.9868  \n",
       "2021-12-30  55.6938  124537.3562  \n",
       "...             ...          ...  \n",
       "2014-07-09      NaN          NaN  \n",
       "2014-07-08      NaN          NaN  \n",
       "2014-07-07      NaN          NaN  \n",
       "2014-07-04      NaN          NaN  \n",
       "2014-07-03      NaN          NaN  \n",
       "\n",
       "[1829 rows x 16 columns]"
      ]
     },
     "execution_count": 625,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df = df['2011-01':]\n",
    "new_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfca5f6f",
   "metadata": {},
   "source": [
    "# 计算每个月第一个交易日买入一首 每年最后一个交易日卖出当年所买股票的盈亏"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 626,
   "id": "05c418f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp/ipykernel_3304/3202183475.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  new_df['date'] = new_df.index\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2014-07-03</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>20.32</td>\n",
       "      <td>24.38</td>\n",
       "      <td>16.93</td>\n",
       "      <td>7.45</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>3956.52</td>\n",
       "      <td>9623.016</td>\n",
       "      <td>28.068</td>\n",
       "      <td>105290.542</td>\n",
       "      <td>27.3955</td>\n",
       "      <td>83068.3640</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-08-01</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>26.50</td>\n",
       "      <td>26.55</td>\n",
       "      <td>25.77</td>\n",
       "      <td>25.80</td>\n",
       "      <td>26.61</td>\n",
       "      <td>-0.81</td>\n",
       "      <td>-3.0400</td>\n",
       "      <td>47059.24</td>\n",
       "      <td>123269.104</td>\n",
       "      <td>26.360</td>\n",
       "      <td>41167.178</td>\n",
       "      <td>27.4560</td>\n",
       "      <td>86673.8850</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-09-01</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>26.07</td>\n",
       "      <td>26.47</td>\n",
       "      <td>25.97</td>\n",
       "      <td>26.43</td>\n",
       "      <td>26.11</td>\n",
       "      <td>0.32</td>\n",
       "      <td>1.2300</td>\n",
       "      <td>19317.55</td>\n",
       "      <td>50650.954</td>\n",
       "      <td>26.060</td>\n",
       "      <td>21518.916</td>\n",
       "      <td>26.6145</td>\n",
       "      <td>36032.1915</td>\n",
       "      <td>26.9560</td>\n",
       "      <td>54144.2108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-10-08</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>26.65</td>\n",
       "      <td>26.90</td>\n",
       "      <td>26.60</td>\n",
       "      <td>26.82</td>\n",
       "      <td>26.65</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.6400</td>\n",
       "      <td>22478.77</td>\n",
       "      <td>60184.809</td>\n",
       "      <td>26.562</td>\n",
       "      <td>22059.546</td>\n",
       "      <td>26.6060</td>\n",
       "      <td>27347.2580</td>\n",
       "      <td>26.5370</td>\n",
       "      <td>33756.3418</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-11-03</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>27.39</td>\n",
       "      <td>27.40</td>\n",
       "      <td>26.96</td>\n",
       "      <td>27.07</td>\n",
       "      <td>27.40</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-1.2000</td>\n",
       "      <td>42778.82</td>\n",
       "      <td>116095.448</td>\n",
       "      <td>26.878</td>\n",
       "      <td>39066.562</td>\n",
       "      <td>26.6705</td>\n",
       "      <td>33696.4695</td>\n",
       "      <td>26.6696</td>\n",
       "      <td>31331.9030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-01</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>41.76</td>\n",
       "      <td>44.56</td>\n",
       "      <td>40.83</td>\n",
       "      <td>43.94</td>\n",
       "      <td>42.02</td>\n",
       "      <td>1.92</td>\n",
       "      <td>4.5693</td>\n",
       "      <td>153733.43</td>\n",
       "      <td>662183.745</td>\n",
       "      <td>42.592</td>\n",
       "      <td>143935.408</td>\n",
       "      <td>42.9370</td>\n",
       "      <td>126017.1880</td>\n",
       "      <td>48.5362</td>\n",
       "      <td>138379.8284</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-08</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>46.00</td>\n",
       "      <td>47.50</td>\n",
       "      <td>45.00</td>\n",
       "      <td>47.12</td>\n",
       "      <td>45.30</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.0177</td>\n",
       "      <td>111272.48</td>\n",
       "      <td>520458.842</td>\n",
       "      <td>46.080</td>\n",
       "      <td>134237.062</td>\n",
       "      <td>44.4525</td>\n",
       "      <td>107563.6410</td>\n",
       "      <td>44.1764</td>\n",
       "      <td>129389.8938</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-01</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>51.00</td>\n",
       "      <td>54.25</td>\n",
       "      <td>49.51</td>\n",
       "      <td>52.67</td>\n",
       "      <td>49.32</td>\n",
       "      <td>3.35</td>\n",
       "      <td>6.7924</td>\n",
       "      <td>292112.42</td>\n",
       "      <td>1544868.504</td>\n",
       "      <td>49.164</td>\n",
       "      <td>173852.670</td>\n",
       "      <td>47.2590</td>\n",
       "      <td>148586.6160</td>\n",
       "      <td>45.0302</td>\n",
       "      <td>127856.8876</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-01</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>57.40</td>\n",
       "      <td>57.78</td>\n",
       "      <td>55.71</td>\n",
       "      <td>56.46</td>\n",
       "      <td>56.45</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.0177</td>\n",
       "      <td>84982.24</td>\n",
       "      <td>479481.860</td>\n",
       "      <td>57.614</td>\n",
       "      <td>104218.422</td>\n",
       "      <td>56.4125</td>\n",
       "      <td>105014.6715</td>\n",
       "      <td>50.4464</td>\n",
       "      <td>124976.8318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-04</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>54.40</td>\n",
       "      <td>54.69</td>\n",
       "      <td>52.56</td>\n",
       "      <td>53.75</td>\n",
       "      <td>54.40</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-1.1949</td>\n",
       "      <td>84020.93</td>\n",
       "      <td>447463.911</td>\n",
       "      <td>55.046</td>\n",
       "      <td>98373.016</td>\n",
       "      <td>57.5270</td>\n",
       "      <td>120488.8350</td>\n",
       "      <td>55.8966</td>\n",
       "      <td>119760.4852</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              ts_code   open   high    low  close  pre_close  change  pct_chg  \\\n",
       "date                                                                            \n",
       "2014-07-03  603369.SH  20.32  24.38  20.32  24.38      16.93    7.45  44.0000   \n",
       "2014-08-01  603369.SH  26.50  26.55  25.77  25.80      26.61   -0.81  -3.0400   \n",
       "2014-09-01  603369.SH  26.07  26.47  25.97  26.43      26.11    0.32   1.2300   \n",
       "2014-10-08  603369.SH  26.65  26.90  26.60  26.82      26.65    0.17   0.6400   \n",
       "2014-11-03  603369.SH  27.39  27.40  26.96  27.07      27.40   -0.33  -1.2000   \n",
       "...               ...    ...    ...    ...    ...        ...     ...      ...   \n",
       "2021-09-01  603369.SH  41.76  44.56  40.83  43.94      42.02    1.92   4.5693   \n",
       "2021-10-08  603369.SH  46.00  47.50  45.00  47.12      45.30    1.82   4.0177   \n",
       "2021-11-01  603369.SH  51.00  54.25  49.51  52.67      49.32    3.35   6.7924   \n",
       "2021-12-01  603369.SH  57.40  57.78  55.71  56.46      56.45    0.01   0.0177   \n",
       "2022-01-04  603369.SH  54.40  54.69  52.56  53.75      54.40   -0.65  -1.1949   \n",
       "\n",
       "                  vol       amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "date                                                                           \n",
       "2014-07-03    3956.52     9623.016  28.068  105290.542  27.3955   83068.3640   \n",
       "2014-08-01   47059.24   123269.104  26.360   41167.178  27.4560   86673.8850   \n",
       "2014-09-01   19317.55    50650.954  26.060   21518.916  26.6145   36032.1915   \n",
       "2014-10-08   22478.77    60184.809  26.562   22059.546  26.6060   27347.2580   \n",
       "2014-11-03   42778.82   116095.448  26.878   39066.562  26.6705   33696.4695   \n",
       "...               ...          ...     ...         ...      ...          ...   \n",
       "2021-09-01  153733.43   662183.745  42.592  143935.408  42.9370  126017.1880   \n",
       "2021-10-08  111272.48   520458.842  46.080  134237.062  44.4525  107563.6410   \n",
       "2021-11-01  292112.42  1544868.504  49.164  173852.670  47.2590  148586.6160   \n",
       "2021-12-01   84982.24   479481.860  57.614  104218.422  56.4125  105014.6715   \n",
       "2022-01-04   84020.93   447463.911  55.046   98373.016  57.5270  120488.8350   \n",
       "\n",
       "               ma50      ma_v_50  \n",
       "date                              \n",
       "2014-07-03      NaN          NaN  \n",
       "2014-08-01      NaN          NaN  \n",
       "2014-09-01  26.9560   54144.2108  \n",
       "2014-10-08  26.5370   33756.3418  \n",
       "2014-11-03  26.6696   31331.9030  \n",
       "...             ...          ...  \n",
       "2021-09-01  48.5362  138379.8284  \n",
       "2021-10-08  44.1764  129389.8938  \n",
       "2021-11-01  45.0302  127856.8876  \n",
       "2021-12-01  50.4464  124976.8318  \n",
       "2022-01-04  55.8966  119760.4852  \n",
       "\n",
       "[91 rows x 16 columns]"
      ]
     },
     "execution_count": 626,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 每月第一个交易日数据 resample这步index会乱 故将索引复制为新列 resample后再次设置index\n",
    "new_df['date'] = new_df.index\n",
    "new_df\n",
    "df_monthly_f = new_df.resample('M').first()\n",
    "df_monthly_f.set_index('date',inplace=True)\n",
    "df_monthly_f "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 627,
   "id": "80d0d7e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "261227.00000000006"
      ]
     },
     "execution_count": 627,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 买入股票的总金额\n",
    "cost = df_monthly_f['open'].sum()*100\n",
    "cost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 628,
   "id": "123151f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>vol</th>\n",
       "      <th>amount</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma_v_5</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma_v_20</th>\n",
       "      <th>ma50</th>\n",
       "      <th>ma_v_50</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2014-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>28.02</td>\n",
       "      <td>28.14</td>\n",
       "      <td>27.56</td>\n",
       "      <td>27.87</td>\n",
       "      <td>28.06</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>-0.6800</td>\n",
       "      <td>20478.91</td>\n",
       "      <td>57003.094</td>\n",
       "      <td>27.858</td>\n",
       "      <td>25300.712</td>\n",
       "      <td>27.9895</td>\n",
       "      <td>32056.0515</td>\n",
       "      <td>28.0854</td>\n",
       "      <td>45655.0848</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>34.39</td>\n",
       "      <td>34.50</td>\n",
       "      <td>33.50</td>\n",
       "      <td>33.53</td>\n",
       "      <td>34.26</td>\n",
       "      <td>-0.73</td>\n",
       "      <td>-2.1300</td>\n",
       "      <td>10559.77</td>\n",
       "      <td>35900.790</td>\n",
       "      <td>34.108</td>\n",
       "      <td>15126.560</td>\n",
       "      <td>34.0020</td>\n",
       "      <td>27208.4415</td>\n",
       "      <td>33.8472</td>\n",
       "      <td>33896.4050</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-30</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>13.00</td>\n",
       "      <td>13.23</td>\n",
       "      <td>13.00</td>\n",
       "      <td>13.12</td>\n",
       "      <td>13.00</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.9200</td>\n",
       "      <td>75511.22</td>\n",
       "      <td>99128.840</td>\n",
       "      <td>13.260</td>\n",
       "      <td>111930.214</td>\n",
       "      <td>13.7015</td>\n",
       "      <td>148521.6655</td>\n",
       "      <td>13.4914</td>\n",
       "      <td>95004.1032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>15.57</td>\n",
       "      <td>15.63</td>\n",
       "      <td>15.31</td>\n",
       "      <td>15.51</td>\n",
       "      <td>15.54</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.1900</td>\n",
       "      <td>74363.83</td>\n",
       "      <td>114992.543</td>\n",
       "      <td>15.308</td>\n",
       "      <td>104009.854</td>\n",
       "      <td>14.6215</td>\n",
       "      <td>78861.7370</td>\n",
       "      <td>15.1268</td>\n",
       "      <td>111103.9186</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-28</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>14.46</td>\n",
       "      <td>14.68</td>\n",
       "      <td>14.03</td>\n",
       "      <td>14.49</td>\n",
       "      <td>14.42</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.4854</td>\n",
       "      <td>63897.27</td>\n",
       "      <td>91789.982</td>\n",
       "      <td>14.674</td>\n",
       "      <td>57162.986</td>\n",
       "      <td>15.3945</td>\n",
       "      <td>62497.9345</td>\n",
       "      <td>15.3492</td>\n",
       "      <td>93908.0344</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>32.60</td>\n",
       "      <td>32.85</td>\n",
       "      <td>31.94</td>\n",
       "      <td>32.72</td>\n",
       "      <td>32.31</td>\n",
       "      <td>0.41</td>\n",
       "      <td>1.2690</td>\n",
       "      <td>146269.23</td>\n",
       "      <td>475028.849</td>\n",
       "      <td>30.716</td>\n",
       "      <td>105808.232</td>\n",
       "      <td>30.2830</td>\n",
       "      <td>84945.3225</td>\n",
       "      <td>30.8458</td>\n",
       "      <td>77904.5628</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>56.70</td>\n",
       "      <td>58.00</td>\n",
       "      <td>55.70</td>\n",
       "      <td>57.38</td>\n",
       "      <td>56.75</td>\n",
       "      <td>0.63</td>\n",
       "      <td>1.1101</td>\n",
       "      <td>159442.36</td>\n",
       "      <td>907850.452</td>\n",
       "      <td>56.312</td>\n",
       "      <td>164522.256</td>\n",
       "      <td>54.7820</td>\n",
       "      <td>161364.6695</td>\n",
       "      <td>52.5380</td>\n",
       "      <td>153807.5556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>603369.SH</td>\n",
       "      <td>55.60</td>\n",
       "      <td>55.60</td>\n",
       "      <td>53.92</td>\n",
       "      <td>54.40</td>\n",
       "      <td>55.18</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>-1.4136</td>\n",
       "      <td>88366.19</td>\n",
       "      <td>480203.487</td>\n",
       "      <td>55.472</td>\n",
       "      <td>103132.294</td>\n",
       "      <td>57.6735</td>\n",
       "      <td>120670.0260</td>\n",
       "      <td>55.7864</td>\n",
       "      <td>121287.9868</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              ts_code   open   high    low  close  pre_close  change  pct_chg  \\\n",
       "date                                                                            \n",
       "2014-12-31  603369.SH  28.02  28.14  27.56  27.87      28.06   -0.19  -0.6800   \n",
       "2015-12-31  603369.SH  34.39  34.50  33.50  33.53      34.26   -0.73  -2.1300   \n",
       "2016-12-30  603369.SH  13.00  13.23  13.00  13.12      13.00    0.12   0.9200   \n",
       "2017-12-29  603369.SH  15.57  15.63  15.31  15.51      15.54   -0.03  -0.1900   \n",
       "2018-12-28  603369.SH  14.46  14.68  14.03  14.49      14.42    0.07   0.4854   \n",
       "2019-12-31  603369.SH  32.60  32.85  31.94  32.72      32.31    0.41   1.2690   \n",
       "2020-12-31  603369.SH  56.70  58.00  55.70  57.38      56.75    0.63   1.1101   \n",
       "2021-12-31  603369.SH  55.60  55.60  53.92  54.40      55.18   -0.78  -1.4136   \n",
       "\n",
       "                  vol      amount     ma5      ma_v_5     ma20      ma_v_20  \\\n",
       "date                                                                          \n",
       "2014-12-31   20478.91   57003.094  27.858   25300.712  27.9895   32056.0515   \n",
       "2015-12-31   10559.77   35900.790  34.108   15126.560  34.0020   27208.4415   \n",
       "2016-12-30   75511.22   99128.840  13.260  111930.214  13.7015  148521.6655   \n",
       "2017-12-29   74363.83  114992.543  15.308  104009.854  14.6215   78861.7370   \n",
       "2018-12-28   63897.27   91789.982  14.674   57162.986  15.3945   62497.9345   \n",
       "2019-12-31  146269.23  475028.849  30.716  105808.232  30.2830   84945.3225   \n",
       "2020-12-31  159442.36  907850.452  56.312  164522.256  54.7820  161364.6695   \n",
       "2021-12-31   88366.19  480203.487  55.472  103132.294  57.6735  120670.0260   \n",
       "\n",
       "               ma50      ma_v_50  \n",
       "date                              \n",
       "2014-12-31  28.0854   45655.0848  \n",
       "2015-12-31  33.8472   33896.4050  \n",
       "2016-12-30  13.4914   95004.1032  \n",
       "2017-12-29  15.1268  111103.9186  \n",
       "2018-12-28  15.3492   93908.0344  \n",
       "2019-12-31  30.8458   77904.5628  \n",
       "2020-12-31  52.5380  153807.5556  \n",
       "2021-12-31  55.7864  121287.9868  "
      ]
     },
     "execution_count": 628,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 每年最后一个交易日 剔除当前年 因当前年最后一个交易日还未到\n",
    "df_yearly_l = new_df.resample('Y').last()[:-1]\n",
    "df_yearly_l.set_index('date',inplace=True)\n",
    "df_yearly_l "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 629,
   "id": "6e2ccf39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300408.0"
      ]
     },
     "execution_count": 629,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 卖出股票的总金额 不包含当年买入的\n",
    "resv = df_yearly_l['open'].sum()*1200\n",
    "resv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 630,
   "id": "5d4b79d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "63264.0"
      ]
     },
     "execution_count": 630,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 当年买入的用当前最近交易日收盘价计算\n",
    "last_money = new_df['close'][0] * max(df_yearly_l.index).month * 100\n",
    "last_money"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 631,
   "id": "a89e95b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "102444.99999999994"
      ]
     },
     "execution_count": 631,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最终受益\n",
    "last = resv + last_money - cost\n",
    "last"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "554920a9",
   "metadata": {},
   "source": [
    "# 均线计算及绘图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 632,
   "id": "cd758e2e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算5日均线\n",
    "ma5 = df.iloc[::-1]['close'].rolling(5).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 633,
   "id": "87ea9a81",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算10日均线\n",
    "ma10 = df.iloc[::-1]['close'].rolling(10).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 634,
   "id": "6da82e0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算30日均线\n",
    "ma30 = df.iloc[::-1]['close'].rolling(30).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 635,
   "id": "db4f2ceb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算50日均线\n",
    "ma50 = df.iloc[::-1]['close'].rolling(50).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 636,
   "id": "99536c82",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 637,
   "id": "d59d40d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x19de7c40>]"
      ]
     },
     "execution_count": 637,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABiY0lEQVR4nO2ddXhUR/fHP7PZuLsCEdwluEOhlFJK3b2l7Vvq7n3r8qv3rXsLpV5aoEhxiruHhCQQI+6+u/P7425CZJdsPIT5PM8+m3vvzNxzCfnu7Jkz5wgpJQqFQqHovOja2wCFQqFQtC5K6BUKhaKTo4ReoVAoOjlK6BUKhaKTo4ReoVAoOjn69jbAEn5+fjI8PLy9zVAoFIozhp07d2ZJKf0tXeuQQh8eHs6OHTva2wyFQqE4YxBCHLd2TbluFAqFopOjhF6hUCg6OUroFQqFopOjhF6hUCg6OUroFQqFopOjhF6hUCg6OUroFQqFopOjhF6hUHQaErOKWXMko73N6HAooVcoFJ2G/62J4/bvdlJWaWxvUzoUSugVCkWn4XhOCRVGE3uT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mfvca1tbSi0HfEZzZfvwiY35a/75Z4/rrjWDhv8W+8TpsmC71y3TQTIUQ42ifuViBQSplmvnQSCLTQ5Rbg70bexloW0CxAX+Mr/KXUzi3UKrTRM58OW+7ZKnSAZ29zOtgz39yKY1ukpZ6/zjh1sTnTb1NQxcGbgRDCDfgVuE9KWSCEqL4mpZRCCFmn/WS0/wTjWuL+5ntcCbwthHAEVgANpphoDu39zHWxdM/WoqM9e1vQkZ5ZCPEkWiqV+S099mnu2SLPX3ecVje8DmpG30SEEPZov7j5UsrfzKfThRDB5uvBQEaN9gPRCrdcKKXMbmDsLkKIPebXHZwmC6iUcrOUcryUcgSwHs0H2Cq08TOfDqv3bC060LO3GR3pmYUQNwKzgGuk2Y/R2rTU81sapzF/4y1CW/u6OsMLEMC3wDt1zr9B7YWa180/d0WrrjXGynjhnN4vqQfigQhOLdT0M18LML87omUHndIZnvl07azds7P8vm1pR+svxnaYZ0YrQ3oI8G/N33NrPL+1cSzcz+rfeI02iajF2LZ7oX0tk8A+YI/5NROt8tYqIBb4B/Axt/8cra5uVdsdNcb6AUgDKtH8chajZszjH0VbmX+yzn+8w2iLRPd1sme22M7aPc+SZ7/IfFwOpFNjAa8TP3Mcmv+6auyPz5S/cWvjNPJv/B7zv4cBSAU+b+zzqBQICoVC0clRPnqFQqHo5CihVygUik6OEnqFQqHo5CihVygUik6OEnqFQqHo5CihVygUik6OEnqFQqHo5Pw/+XmXNrbgU3sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(df.iloc[::-1]['close'][-100:len(df['close'])])\n",
    "plt.plot(ma5[-100:len(ma5)])\n",
    "# plt.plot(ma10[-100:len(ma10)])\n",
    "plt.plot(ma30[-100:len(ma30)])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff13ff48",
   "metadata": {},
   "source": [
    "# 分析输出金叉日期和死叉日期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 638,
   "id": "1547e4ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "n = 30\n",
    "ma1 = ma5[n:]\n",
    "ma2 = ma30[n:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 639,
   "id": "4ffe3040",
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = ma1 < ma2\n",
    "s2 = ma1 > ma2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 640,
   "id": "a2c04fb2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 死叉\n",
    "death_ex = s1 & s2.shift(1)\n",
    "death_ex_date = df.iloc[::-1][n:].loc[death_ex].index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 641,
   "id": "8a46dc2a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 金叉\n",
    "golden_ex = ~(s1 | s2.shift(1))\n",
    "golden_ex_date = df.iloc[::-1][n:].loc[golden_ex].index"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71891b3a",
   "metadata": {},
   "source": [
    "# 从2020.01开始 初始资金100000 金叉买入 死叉卖出 计算收益"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 642,
   "id": "309c5f61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "trade_date\n",
       "2020-02-03    0\n",
       "2020-02-25    1\n",
       "2020-02-28    0\n",
       "2020-03-06    1\n",
       "2020-03-18    0\n",
       "2020-04-15    1\n",
       "2020-08-06    0\n",
       "2020-08-14    1\n",
       "2020-09-16    0\n",
       "2020-10-16    1\n",
       "2020-11-27    0\n",
       "2020-12-10    1\n",
       "2021-01-21    0\n",
       "2021-02-05    1\n",
       "2021-02-19    0\n",
       "2021-03-31    1\n",
       "2021-06-15    0\n",
       "2021-07-12    1\n",
       "2021-07-26    0\n",
       "2021-09-06    1\n",
       "2021-09-17    0\n",
       "2021-09-27    1\n",
       "2021-12-27    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 642,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1作为金叉标志\n",
    "s1 = Series(data=1,index=golden_ex_date)\n",
    "# 0作为死叉标志\n",
    "s2 = Series(data=0,index=death_ex_date)\n",
    "# 金叉死叉对应的时间\n",
    "s = s1.append(s2).sort_index()['2020-01-01':]\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 643,
   "id": "fba05467",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 本金\n",
    "first_money = 10000 # 记录初始本金\n",
    "cur_money = first_money # \n",
    "hold = 0 # 持有股数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 644,
   "id": "8cb5e400",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(0,len(s)):\n",
    "    if s[i] == 1:\n",
    "        # 金叉 基于剩余本金尽可能多的买入\n",
    "        # 获取股票单价 金叉时间对应行数据中的开盘价\n",
    "        time = s.index[i] # 金叉时间\n",
    "        p = df.loc[time]['open']\n",
    "        hand_count = cur_money // (p*100)\n",
    "        hold += hand_count * 100\n",
    "        cur_money -= (hold * p) # 将买股票花费的金额减去\n",
    "    else:\n",
    "        # 死叉 将已买入的股票卖出\n",
    "        # 找出卖出股票的单价\n",
    "        death_time = s.index[i] # 死叉时间\n",
    "        p = df.loc[death_time]['open'] # 单价\n",
    "        cur_money += (p * hold)\n",
    "        hold = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 645,
   "id": "2944cb01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18579.0"
      ]
     },
     "execution_count": 645,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cur_money"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 646,
   "id": "dd07f763",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 646,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 647,
   "id": "0f639d48",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8579.0"
      ]
     },
     "execution_count": 647,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_money = cur_money + hold * df['close'][0] - first_money\n",
    "final_money"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a36f7ce",
   "metadata": {},
   "source": [
    "# 金叉后一天买入 死叉后一天卖出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 648,
   "id": "b842f958",
   "metadata": {},
   "outputs": [],
   "source": [
    "first_money = 10000 # 记录初始本金\n",
    "cur_money = first_money # \n",
    "hold = 0 # 持有股数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 649,
   "id": "2a5c0195",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(0,len(s)):\n",
    "    if s[i] == 1:\n",
    "        # 金叉 基于剩余本金尽可能多的买入\n",
    "        # 获取股票单价 金叉时间对应行数据中的开盘价\n",
    "        time = s.index[i] # 金叉时间\n",
    "        index = df.index.get_loc(time)\n",
    "        if index > 0 :\n",
    "            p = df.loc[df.index[index - 1]]['open']\n",
    "            hand_count = cur_money // (p*100)\n",
    "            hold += hand_count * 100\n",
    "            cur_money -= (hold * p) # 将买股票花费的金额减去\n",
    "    else:\n",
    "        # 死叉 将已买入的股票卖出\n",
    "        # 找出卖出股票的单价\n",
    "        death_time = s.index[i] # 死叉时间\n",
    "        index = df.index.get_loc(death_time)\n",
    "        if index > 0 :\n",
    "            p = df.loc[df.index[index - 1]]['open'] # 单价\n",
    "            cur_money += (p * hold)\n",
    "            hold = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 650,
   "id": "1a647fe8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3000.0"
      ]
     },
     "execution_count": 650,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_money = cur_money + hold * df['close'][0] - first_money\n",
    "final_money"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7983e23",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1433bd9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5819f234",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
